<template>
  <div class="footer-box" id="myPopup-template5-footer" :class="{ 'template5-menu-loop': route.meta.loopType }">
    <img src="@/assets/templateImg/floter1.png" alt="" class="footer-box-bgc" />
    <div class="footer-logo">
      <!-- @/assets/templateImg/floter1.png -->
      <img
        class="t-image--fit-contain t-image--position-center"
        :src="$filters.getLinkUrl(store.styleInfo.logo, '?imageView2/2/w/380/h/100/format/webp')"
        alt=""
        v-if="store.styleInfo.logo"
      />
    </div>
    <div class="footer-tab"></div>

    <div class="footer-menus">
      <!-- 箭头向上 -->
      <div v-if="tabListType" class="blank-top" @click.stop="blankTop" :style="{ background: 'rgba(0,0,0,.1)' }">
        <img src="@/assets/templateImg/template5Shearicon3.png" alt="" />
      </div>
    </div>

    <div class="btm-os">
      <img src="../../../../assets/templateImg/doorLogo.svg" alt="" />
      <span>· 永不落幕的展览与展示平台</span>
    </div>
  </div>
</template>

<script setup lang="ts">
// @ts-nocheck
// doorLogo.svg
import doorlogo from '@/assets/templateImg/doorLogo.svg';
import { toQQzone, toQQ, toWeibo, toWechat } from '@/utils/shear';
import shear from '@/components/shear/shear.vue';
import { ImgUrlCancat, doorUrl } from '@/utils/minxin';
import strat from '@/components/start/start.vue';
import { pathList, pathListLoop } from '../index';
import { colorList5 } from '../../data';
import { ref, watch, computed, onMounted, onBeforeUnmount, nextTick } from 'vue';
import { urls } from '@/utils/request/upload';
import { useProjectStore } from '@/store';
import { settings } from '@/api/project/project';
import { storeToRefs } from 'pinia';
import { useRouter, useRoute } from 'vue-router';
import { templateIsFollow } from '@/api/project/project';
import { AddFollow } from '@/api/door/door';

const viewportHeight = ref(0);
const route = useRoute();
const tabListType = ref(false);
const router = useRouter();
const FollowType = ref(false);
const info = ref({
  digitalShowroom: null,
});
const bgcUrl = ref('@/assets/templateImg/floter1.png');
const tabList = ref([]);
const init = () => {
  templateIsFollow(localStorage.getItem('projectId')).then((res) => {
    if (res.statusCode == 200) {
      FollowType.value = res.data;
    }
  });
};
viewportHeight.value = window.innerHeight;
const handleFixedChange = (e) => {
  const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
  if (scrollTop < viewportHeight.value - 220) {
    tabListType.value = false;
  } else {
    tabListType.value = true;
  }
};
// const initprojectDetail = async () => {
//   try {
//     let res = await projectDetail(localStorage.getItem('projectId'));
//     info.value = res.data;
//   } catch (err) {}
// };
// initprojectDetail();
onMounted(() => {
  nextTick(() => {
    window.addEventListener('scroll', handleFixedChange);
  });
});

onBeforeUnmount(() => {
  window.removeEventListener('scroll', handleFixedChange);
});
const shearType = (e: number) => {
  //分享
  let url = window.location.href;
  let title = window.document.title;
  switch (e) {
    case 1:
      toQQzone(url, title);
      break;
    case 2:
      toQQ(url, title);
      break;
    case 3:
      toWeibo(url, title);
      break;
    default:
      toWechat(url, title);
      break;
  }
};
const blankTop = () => {
  window.scrollTo({
    top: 0,
    behavior: 'smooth', // 设置滚动的动画效果
  });
};
const setFollow = async () => {
  try {
    let { data } = await AddFollow({
      refType: 3,
      refId: localStorage.getItem('projectId'),
    });
    FollowType.value = data;
  } catch {}
};
// init();
const store = useProjectStore();
const { tabvalue } = storeToRefs(store);
const props = defineProps({
  modelValue: {
    type: Number,
  },
  background: {
    type: String,
    default: '#CFBDA8',
  },
  color: {
    type: String,
    default: '#ffffff',
  },
});
const emit = defineEmits(['update:modelValue', 'setCruuent']);
const setCruuent = (e: number) => {
  // emit('update:modelValue', e);
  // emit('setCruuent', e);

  let urlLink: string = '';
  // return;
  switch (e) {
    case 0: //首页
      urlLink = route.meta.loopType ? pathListLoop[0] : pathList[0];
      break;
    case 1: //展品图库
      urlLink = route.meta.loopType ? pathListLoop[2] : pathList[2];
      break;
    case 4: //文创商品
      urlLink = route.meta.loopType ? pathListLoop[1] : pathList[1];
      break;
    case 5: //版权声明
      urlLink = route.meta.loopType ? pathListLoop[3] : pathList[3];
      break;
    case 3: //学术研究
      urlLink = route.meta.loopType ? pathListLoop[5] : pathList[5];
      break;
    case 2: //留言板
      urlLink = route.meta.loopType ? pathListLoop[4] : pathList[4];
      break;
    default:
      break;
  }
  store.setHeartbeatCurrent();
  router.push({
    name: urlLink,
  });
  console.log(e);

  setTimeout(() => {
    const ele = document.getElementById('timeAxis-child-box-id'); // 获取元素
    const top = ele.offsetTop - 220; // 获取元素距离文档顶部的距离
    window.scrollTo({
      top: top,
      behavior: 'smooth', // 设置滚动的动画效果
    });
  }, 0);
};
const getBgcUrl = computed(() => {
  // switch (store.styleInfo.colorType) {
  //   case 1:
  //     return '@/assets/templateImg/floter1.png';
  //     break;
  //   case 2:
  //     return '@/assets/templateImg/floter2.png';
  //     break;
  //   default:
  //     return '@/assets/templateImg/floter3.png';
  //     break;
  // }
});
</script>

<style lang="less" scoped>
.footer-box {
  position: relative;
  width: 100%;
  height: 356px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 0;
  padding-bottom: 0px;
}
.footer-logo {
  position: relative;
  z-index: 6;
  width: 380px;
  height: 100px;
  // background: #d8d8d8;
  margin-top: 80px;
  margin-bottom: 40px;
  img {
    width: 380px;
    height: 100px;
  }
}
.footer-tab {
  position: relative;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-bottom: 32px;
  height: 22px;
  .tab-item {
    cursor: pointer;
    font-size: 16px;
    font-weight: 400;
    line-height: 22px;
    padding: 0 40px;
    border-right: 1px solid #ffffff;
  }
  .item-right-border {
    border: none;
  }
}
.footer-title1 {
  position: relative;
  z-index: 6;
  font-size: 16px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #ffffff;
  line-height: 22px;
}
.footer-title2 {
  margin-top: 8px;
}
.footer-box-bgc {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 356px;
}
.footer-menus {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  position: fixed;
  z-index: 99999;
  bottom: 80px;
  right: 30px;
  width: 50px;
  img {
    width: 50px;
  }
  .tip {
    white-space: nowrap;
  }
}

.star-box {
  margin-bottom: 12px;
  :deep(.star-box-pablish) {
    cursor: pointer;
    position: relative;
    z-index: 99999;
    bottom: 0px;
    right: 0px;
    width: 50px;
    height: 50px;
    border-radius: 50%;

    background: rgba(0, 0, 0, 0.2);
    img {
      width: 50px;
      height: 50px;
    }
  }
  :deep(#template3-box .t-popup__content) {
    background-color: #fff !important;
    border-color: #fff;
    color: #333 !important;
    text-align: center;
  }
  :deep(.t-popup__arrow) {
    display: none !important;
  }
}
.shear-box {
  cursor: pointer;
  position: relative;
  z-index: 99999;
  width: 50px;
  height: 50px;
  margin-bottom: 12px;
}
.blank-top {
  cursor: pointer;
  position: relative;
  z-index: 99999;
  bottom: 0px;
  right: 0px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  img {
    width: 50px;
    height: 50px;
  }
}
.template5-menu-loop {
  .footer-menus {
    right: 30px;
  }
}
.item-right-border {
  border-right: none;
}
.btm-os {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 100%;
  height: 50px;
  z-index: 666;
  background: rgba(0, 0, 0, 0.1);
  img {
    width: auto;
    min-width: 26px;
    height: 26px;
    object-fit: contain;
    margin-right: 8px;
  }
  span {
    font-family: PingFang SC;
    font-size: 16px;
    font-weight: 400;
    line-height: 22px;
    color: #ffffff;
  }
}
</style>
